package cz.cernilovsky.android.profileapp.model;

import java.io.Serializable;

import android.content.Context;

public class Profile implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -9037680109742537190L;
	private int id;
	private String name;
	private Action wifi;
	private Action sounds;
	private Action bluetooth;
	public Profile(String name, Action wifi, Action sounds, Action bluetooth) {
		super();
		this.name = name;
		this.wifi = wifi;
		this.sounds = sounds;
		this.bluetooth = bluetooth;
	}
	public Profile(int id, String name, Action wifi, Action sounds, Action bluetooth) {
		this(name, wifi, sounds, bluetooth);
		this.id = id;
	}
	public boolean process(Context context) {
		boolean somethingProcessed = false;
		if(wifi != null) {
			if(wifi.perform(context)) {
				somethingProcessed = true;
			}
		}
		if(sounds != null) {
			if(sounds.perform(context)) {
				somethingProcessed = true;
			}
		}
		if(bluetooth != null) {
			if(bluetooth.perform(context)) {
				somethingProcessed = true;
			}
		}
		return somethingProcessed;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Action getWifi() {
		return wifi;
	}
	public void setWifi(Action wifi) {
		this.wifi = wifi;
	}
	public Action getSounds() {
		return sounds;
	}
	public void setSounds(Action sounds) {
		this.sounds = sounds;
	}
	public Action getBluetooth() {
		return bluetooth;
	}
	public void setBluetooth(Action bluetooth) {
		this.bluetooth = bluetooth;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Profile other = (Profile) obj;
		if (id != other.id)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return getName();
	}
	
}
